﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<t_205_verk_hopur_12.Models.ChannelIndexViewModel>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	<%= Html.Encode(Model.Channel.Name) %>
</asp:Content>

<asp:Content ID="Content4" ContentPlaceHolderID="MenuBar" runat="server">
    <% Html.RenderPartial("ChannelMenuBar", new t_205_verk_hopur_12.Models.ChannelMenuViewModel(Model.Channel, Model.IsOwnerOrEmployee)); %>
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <div id="NowPlaying">
        <% if (Model.CurrentSchedule == null)
           { %>
                <h2>Ekkert myndband er á dagskrá þessa stundina</h2>
        <% } %>
        <% else 
           {%>
            <h2>
                <%= Html.Encode(Model.CurrentSchedule.Title)%>
            </h2>
            <%= Model.CurrentSchedule.Embed%>
            <p>&nbsp;   </p>
            <p>
                <b>Lýsing:</b>
            </p>
            <p>
                <%= Html.Encode(Model.CurrentSchedule.Description)%>
            </p>
            <p>&nbsp;</p>
            <p>
                <b>Einkun:</b> <%= Model.CurrentSchedule.Rating %>
            </p>
            <p>&nbsp;</p>
            <p>
                <% if(Page.User.Identity.Name != ""){ %>
                    <% if (!Model.HasUserVotedVideo)
                       { %>
                        Líkar þér þessi dagskrárliður?
                        <span id="HiddenAjax2"><img src="/Content/Icons/ajax.gif" alt="Hleður" title="Hleður" /></span>
                        <span id="RateVideo">
                        <%= Ajax.ActionLink("__IMGREPLACE__", "VoteVideo", "Channel", new { videoID = Model.CurrentSchedule.VideoID, vote = 1 }, new AjaxOptions { HttpMethod = "POST", UpdateTargetId = "RateVideo", OnBegin = "showHiddenAjax2", OnComplete = "hideHiddenAjax2" }).ToString().Replace("__IMGREPLACE__", "<img src='/Content/Icons/thumb_up.png' alt='Líkar' title='Líkar' />")%>
                        <%= Ajax.ActionLink("__IMGREPLACE__", "VoteVideo", "Channel", new { videoID = Model.CurrentSchedule.VideoID, vote = -1 }, new AjaxOptions { HttpMethod = "POST", UpdateTargetId = "RateVideo", OnBegin = "showHiddenAjax2", OnComplete = "hideHiddenAjax2" }).ToString().Replace("__IMGREPLACE__", "<img src='/Content/Icons/thumb_down.png' alt='Líkar ekki' title='Líkar ekki' />")%>
                        </span>
                    <% } else { %>
                        <img src="/Content/Icons/information.png" alt="Þú ert búinn að kjósa" title="Þú ert búinn að kjósa" /> Þú ert búinn að kjósa um þetta myndband
                    <% } %>
                <% } %>
            </p>
            <p>&nbsp;</p>
        <% } %>
        <h2><%= Model.Channel.Name %></h2>
        <div class="display-label">Eigandi</div>
        <div class="display-field">
        <% if (Model.Owner.Username == Page.User.Identity.Name)
           { %>
                <%= Html.ActionLink(Model.Owner.Username, "Index", "User", new { id = Model.Owner.ID }, null)%>
        <% } %>
        <% else
            { %>
                <%= Html.ActionLink(Model.Owner.Username, "Details", "User", new { id = Model.Owner.ID }, null)%>
         <% } %>
        </div>
        <div class="clear"></div>
        <div class="display-label">Lýsing</div>
        <div class="display-field"><%= Html.Encode(Model.Channel.Description)%></div>
        <div class="clear"></div>
        
        <div class="display-label">Einkun</div>
        <div class="display-field"><%= Html.Encode(Model.Channel.Rating)%></div>
        <div class="clear"></div>
        
        <div class="display-label">Stjórnsýsla</div>
        <div class="display-field"><%= (Model.Channel.Autocracy ? "Lýðræðisstöð" : "Einræðisstöð") %></div>
        <div class="clear"></div>
        
        <div class="display-label">Flokkur</div>
        <div class="display-field"><%= Html.Encode(Model.Category.Name)%></div>
        <div class="clear"></div>
        <% if (!Model.IsOwnerOrEmployee)
           { %>
        <div id="Application">
            <p>
            <% if (Page.User.Identity.Name != "")
               { %>
                <%if (!Model.HasAppliedToChannel)
                  {%>
                <%= Ajax.ActionLink("__IMGREPLACE__ Sækja um starf á stöðinni", "Apply", "Channel", new { id = Model.Channel.ID }, new AjaxOptions { HttpMethod = "POST", UpdateTargetId = "Application" }).ToString().Replace("__IMGREPLACE__", "<img src='/Content/Icons/group_add.png' alt='Sækja um' title='Sækja um' />")%>
                <%}
                  else
                  { %>
                 (Umsókn þín er í vinnslu)
                 <%} %>
                 <%} %>
            </p>
            <p>&nbsp;</p>
        </div>
        <% } %>
        <p>
        <% if(Page.User.Identity.Name != ""){ %>
            <% if (!Model.HasUserVotedChannel)
               { %>
                Líkar þér þessi stöð?
                <span id="HiddenAjax"><img src="/Content/Icons/ajax.gif" alt="Hleður" title="Hleður" /></span>
                <span id="RateChannel">
                    <%= Ajax.ActionLink("__IMGREPLACE__", "VoteChannel", "Channel", new { channelID = Model.Channel.ID, vote = 1 }, new AjaxOptions { HttpMethod = "POST", UpdateTargetId = "RateChannel", OnBegin = "showHiddenAjax", OnComplete = "hideHiddenAjax" }).ToString().Replace("__IMGREPLACE__", "<img src='/Content/Icons/thumb_up.png' alt='Líkar stöðinn' title='Líkar stöðin' />")%>
                    <%= Ajax.ActionLink("__IMGREPLACE__", "VoteChannel", "Channel", new { channelID = Model.Channel.ID, vote = -1 }, new AjaxOptions { HttpMethod = "POST", UpdateTargetId = "RateChannel", OnBegin = "showHiddenAjax", OnComplete = "hideHiddenAjax" }).ToString().Replace("__IMGREPLACE__", "<img src='/Content/Icons/thumb_down.png' alt='Líkar ekki stöðina' title='Líkar ekki stöðina' />")%>        
                </span>
            <% } else { %>
                <img src="/Content/Icons/information.png" alt="Þú ert búinn að kjósa" title="Þú ert búinn að kjósa" /> Þú ert búinn að kjósa þessa stöð
            <% } %>
        <% } %>
        </p>
    </div>
    <div id="OneDaySchedule">
        <span id="HiddenAjax3">
            <img src="/Content/Icons/ajax.gif" alt="Hleður" title="Hleður" />
            <br />
        </span>
        <div id="Subscription">
        <% if (Page.User.Identity.Name != "")
           { %>
            <%if (!Model.IsSubscribedToChannel)
              {%>
            <%= Ajax.ActionLink("__IMGREPLACE__ Gerast áskrifandi", "Subscribe", "Channel", new { id = Model.Channel.ID }, new AjaxOptions { HttpMethod = "POST", UpdateTargetId = "Subscription", OnBegin = "showHiddenAjax3", OnComplete = "hideHiddenAjax3" }).ToString().Replace("__IMGREPLACE__", "<img src='/Content/Icons/heart_add.png' alt='Gerast áskrifandi' title='Gerast áskrifandi' />")%>
            <%}
              else
              { %>
             <%= Ajax.ActionLink("__IMGREPLACE__ Segja upp áskrift", "Unsubscribe", "Channel", new { id = Model.Channel.ID }, new AjaxOptions { HttpMethod = "POST", UpdateTargetId = "Subscription", OnBegin = "showHiddenAjax3", OnComplete = "hideHiddenAjax3" }).ToString().Replace("__IMGREPLACE__", "<img src='/Content/Icons/heart_delete.png' alt='Segja upp áskrift' title='Segja upp áskrift' />")%>
             <%} %>
             <%} %>
            <p>&nbsp;</p>
        </div>    
       <% if (Model.Schedule == null)
          { %>
          <h2>Ekkert er á dagskrá</h2>
       <% } %>
       <% else
           { %>
               <% if(DateTime.Now.ToShortDateString() == Model.Schedule.First().StartTime.ToShortDateString()) 
                  { %>
                    <h2>Dagskráin í dag</h2>
               <% } %>
               <% else 
                  { %>
                    <h2>Dagskráin <%= Model.Schedule.First().StartTime.ToShortDateString() %></h2>
                <% } %>               
              <table class="ScheduleTable">
              <% foreach (var schedule in Model.Schedule)
                 { %>
                    <tr>
                        <td><b><%= Html.Encode(String.Format("{0:00}", schedule.StartTime.Hour))%>:<%= Html.Encode(String.Format("{0:00}", schedule.StartTime.Minute))%></b></td>
                        <td><%= Html.ActionLink(schedule.Title, "Index", "Channel", new { id = Model.Channel.ID, scheduleID = schedule.ID }, null)%></td>
                    </tr>
              <%} %>
              </table>
        <% } %>
        <% if (Model.TopRated != null) { %>
            <% if(Model.TopRated.Count() > 0) { %>
                <p>&nbsp;</p>
                <h2>Vinsælustu myndböndin</h2>
                <% foreach(var topRated in Model.TopRated){ %>
                    <%= Html.ActionLink(topRated.Title, "Index", "Channel", new { id = Model.Channel.ID, scheduleID = topRated.ID }, null)%>
                    <p>&nbsp;</p>
                <% } %>
            <% } %>
        <% } %>
    </div>
    <div class="clear"></div>
    <div id="Announcements">
        <% if(Model.Announcements != null){ %>
            <% if(Model.Announcements.Count() > 0){ %>
                <p>&nbsp;</p>
                <% foreach(var announcement in Model.Announcements){ %>
                    <h2><%= Html.Encode(announcement.Title) %></h2>
                    <p>
                        <% if (Model.Owner.Username == Page.User.Identity.Name)
                           { %>
                                <%= Html.ActionLink(Model.Owner.Username, "Index", "User", new { id = Model.Owner.ID }, null)%>
                        <% } %>
                        <% else
                            { %>
                                <%= Html.ActionLink(Model.Owner.Username, "Details", "User", new { id = Model.Owner.ID }, null)%>
                         <% } %> - 
                        <b><%= Html.Encode(announcement.CreationDate) %></b>
                    </p>
                    <p>&nbsp;</p>
                    <p><%= Html.Encode(announcement.Body).Replace("\n", "<br />")%></p>
                <% } %>
            <% } %>
        <% } %>
    </div>
</asp:Content>

<asp:Content ID="Content3" ContentPlaceHolderID="LogoText" runat="server">
    <%= Html.Encode(Model.Channel.Name) %>
</asp:Content>

